/** API 接口请求,请求方法封装
 *  @version 1.0.0
 *  @author win
 */
const {
  _get,
  _post
} = require("./request.js");


/* ============= GET ================ */
/**
 *获取轮播
 */
const getSwiper = () => _get("/Index/getBanner", {});

/**
 *获取专栏课程
 */
const getFeature = ({
  page = 1,
  keyword = ''
} = {}) => _get("/Special_Column/getSpecialColumnList", {
  page,
  keyword
});

/**
 * 获取分类课程
 * @param type
 * 参数：type,
 * 课程类型，1是视频，2是音频，3是文章 
 */
const getCourseList = ({
  type = '',
  page = 1,
  keyword = ''
} = {}) => _get("/Course/getCourseList", {
  type,
  page,
  keyword
});

/**
 * 获取分类列表页数据
 */
const getCategoryCourseList = ({
  type = 1,
  keyword = '',
  category,
  page = 1
} = {}) => _get(`/Course/getCourseList`, {
  type,
  keyword,
  category,
  page
})

/**
 * 获取课程分类列表
 */
const getCategoryList = () => _get("/Course_Category/getCategoryList", {});

/**
 * 获取消息列表
 * @param type
 * type 消息类型，1是系统消息，2是订单消息，3是收益消息
 */


/**
 * 获取消息列表信息
 */
const getMessageList = (type) => _get("/Message/MessageList", {
  type
});

/**
 * 获取公司简介数据
 */
const getCompanyProfile = () => _get("/Index/getCompanyProfile", {});

/**
 * 获取到联系我们数据
 */
const getAboutUs = () => _get("/Index/getAboutUs", {});

/**
 * 获取资料库分类数据
 */
const getFileList = ({
  page = 1,
  type = 'new',
  keyword = ''
} = {}) => _get("/File_Library/getFileList", {
  type,
  page,
  keyword
});
/**
 *  获取资料库资料列表数据
 *  @param {id}
 */
const getFileInfo = (id) => _get("/File_Library/getFileInfo", {
  id
});
/**
 * 获取订单列表
 *  @param { page, limit, status}
 */
const getOrderList = ({
  page = 1,
  status = 'ALL'
} = {}) => _get("/Order/orderList", {
  page,
  status
});

/**
 * 获取用户信息
 */
const getUserInfo = () => _get("/Center/getUserInfo", {});

/**
 * 获取余额信息
 */
const getBalanceInfo = () => _get("/Balance/balanceInfo", {});

/**
 * 设置用户省市区
 */
const setUserAddress = (province, city, area = "") => _post("/Center/setUserAddress", {
  province,
  city,
  area
})
/**
 * 获取省市区
 */
const getRegion = (region_code) => _get("/Center/region", {
  region_code
})

/**
 * 获取收入记录
 */

const getIncomeLog = (page = 1) => _get("/Balance/incomeLog", {
  page
});

/**
 *  获取提现记录
 */
const getWithDrawLog = (page = 1) => _get("/Balance/withDrawLog", {
  page
})

/**
 * 获取用户vip等级
 */
const getUserLevel = () => _get("/Center/getUserLevel", {});

/**
 * 获取VIP介绍图片
 */
const getVipDescribe = () => _get("/Vip_Package/getVipDescribe", {});

/**
 * 获取专栏详情信息
 */
const getSpecialColumnInfo = (id) => _get(`/Special_Column/getSpecialColumnInfo?id=${id}`, {});

/**
 * 获取到下级列表
 */
const getMyExtractList = () => _get(`/My_Extract/getMyExtractList`, {});

/**
 * 获取课程详细信息
 */
const getCourseInfo = (id) => _get(`/Course/getCourseInfo`, {
  id
});

/**
 *   获取生成分享图片，返回png格式图片
 */
const getShareImage = (type, id, url) => _get(`/Share/shareImage`, {
  type,
  id,
  url
})

/**
 * 获取优惠劵列表
 */
const getCouponList = (type = 1) => _get("/Coupon/getCouponList", {
  type
})
/**
 * 获取专栏下的课程列表
 */
const getSpecialCourse = (id, page = 1, limit = 1000) => _get("/Special_Column/getSpecialCourse", {
  id,
  page,
  limit
})

/**
 * 获取用户观看记录
 */
const getLookHistoryList = ({
  page = 1,
  type = 1
} = {}) => _get("/Look_History/getLookHistoryList", {
  page,
  type
})


/**
 * 获取订单详情信息
 */
const getOrderInfo = (order_number) => _get("Order/orderInfo", {
  order_number
})


/* =============== POST ================= */

/**
 *  设置性别
 */

const setGender = (gender) => _post("/Center/setUserGender", {
  gender
})

/**
 *  获取订单列表
 */
const cancelOrder = ({
  order_number,
  order_type = "goods"
}) => _post("/Order/cancelOrder", {
  order_number,
  order_type
})


/**
 * 获取课时列表
 */
const getSubjectList = () => _get("/Subject/getSubjectList", {

})

/**
 * 兑换优惠券
 */
const setexchangeCoupon = (number) => _post("/Coupon/exchangeCoupon", {
  number
})

/**
 * 添加一条观看记录 
 * 观看的商品ID
 * @param { goods_id }
 */
const addLookHistory = (goods_id, goods_type) => _post("/Look_History/addLookHistory", {
  goods_id,
  goods_type
})


/**
 * 绑定银行卡
 * 银行卡必选字段:
 * @param {必选: 银行名称}    card_bank_name 
 * @param {必选: 所在地信息}  card_address 
 * @param {必选: 支行名称}    card_branch_name 
 * @param {必选: 卡号}        card_number 
 * @param {必选: 用户名}      card_user_name 
 */
const setbindBankCard = (card_bank_name, card_address, card_branch_name, card_number, card_user_name, ) => _post("/Balance/bindBankCard", {
  card_bank_name,
  card_address,
  card_branch_name,
  card_number,
  card_user_name,
})


/**
 * 课程点赞
 */
const setlike = (id) => _post("/Course/like", {
  id
})


export {
  getSwiper,
  getFeature,
  getCourseList,
  getCategoryList,
  getMessageList,
  getCompanyProfile,
  getAboutUs,
  getFileList,
  getFileInfo,
  getOrderList,
  getUserInfo,
  getBalanceInfo,
  getIncomeLog,
  getWithDrawLog,
  getUserLevel,
  getVipDescribe,
  getSpecialColumnInfo,
  getMyExtractList,
  getCouponList,
  getSpecialCourse,
  getLookHistoryList,
  getCategoryCourseList,
  getOrderInfo,
  getCourseInfo,
  addLookHistory,
  setUserAddress,
  setGender,
  cancelOrder,
  setexchangeCoupon,
  setbindBankCard,
  getRegion,
  setlike
}